﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace FileEfCore.DbContexts;

public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<FileDbContext>
{
    public FileDbContext CreateDbContext(string[] args)
    {
        var dbContextOptionsBuilder = new DbContextOptionsBuilder<FileDbContext>();
        var homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
        var dbPath = Path.Combine(homeDir, ".ums-file-client/fileinfo.db");
        var connectionString = $"Data Source={dbPath}";
        dbContextOptionsBuilder.UseSqlite(connectionString);
        return new FileDbContext(dbContextOptionsBuilder.Options);
    }
}